package com.demo.dao;

import com.demo.common.model.Aircraft;
import com.demo.common.model.Airroute;
import com.jfinal.kit.Kv;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.SqlPara;

import java.util.List;

public class AirrouteDao {

    private Airroute dao = new Airroute().dao();

    public Page<Airroute> paginate(int pageNumber, int pageSize) {
        return dao.paginate(pageNumber, pageSize, "select *", "from airroute order by id asc");
    }

    public Page<Airroute> paginate(int pageNumber, int pageSize, Kv cond) {
        SqlPara sqlPara = dao.getSqlPara("searchAirroute",cond);
        return dao.paginate(pageNumber, pageSize, sqlPara);
    }

    public Airroute findById(int id) {
        return dao.findById(id);
    }

    public Airroute findByAirrouteno(String id,String airRouteNo){
        String sql="select * from airroute where airrouteno='"+airRouteNo+"'";
        if(StrKit.notBlank(id)){
            sql+=" and id <>"+id;
        }
        return dao.findFirst(sql);
    }

    public void deleteById(int id) {
        dao.deleteById(id);
    }

    public List<Airroute> findAll() {
        return dao.findAll();
    }
}
